*	LAB3
*	Submitted by : Niket Shah
*	Blink an LED at 1Hz. Also transmit a character 'Y' if the data written and read are the same. Else transmit character 'N'
*	ECEN5613
*	Spring 2011
*	DATE: 21st Feb 2011
*	REV:1.3

			
			ORG $2000				* 	RESET VECTOR	
			LJMP MYCODE				* 	JUMP TO MAIN CODE
			
			ORG $2140				*	MAIN PROGRAM
MYCODE:
			ANL 8EH,#%11111101		*	AUXR Register changed to make EXTRAM = 0 
			ORL 8EH,#%00001100		*	AUXR Register Changed to make XRS0 = XRS1 = 1
			MOV R4,#0AH				*	SET COUNTER FOR VALUE OF 0AH
			MOV IE,#%00000010		*	DISABLE GLOBAL INTERRUT EA=0   ENABLE TIMER INTERRUPT ET0 =1
			MOV IP,#%00000010		* 	TIMER 0 SET TO HIGHEST PRIORITY INTERRUPT
			MOV PSW,#%00000000		*	SELECT REGISTER BANK 0
			MOV TMOD,#%00100001		*	TIMER 0 IN MODE 1
			MOV TCON,#%00000000		*	CLEAR TIMER FLAG TF0 = 0 CLEAR RUN FLAG TR0 =0
			MOV TH0,#4CH			* 	LOAD TIMER HIGHER
			MOV TL0,#00H			* 	LOAD TIMER LOWER
			SETB IE.7				*	ENABLE GLOBAL INTERRUPT   EA=1
			SETB TCON.4				*	START TIMER   TR0=1
			MOV SCON,#50H
			MOV TL1,#00H	
			MOV TH1,#0FDH	
			MOV DPTR,#02FFH
			SETB TCON.6		
HERE:		SJMP HERE

			
			ORG $200B				*	TIMER 0 VECTOR
			SETB P1.0				*	SET SECOND PORT PIN I.E SET PORT PIN1.0
			LJMP MYISR				*	JUMP TO TIMER ISR
			
			
			ORG $2200				*	TIMER ISR
MYISR:		CLR IE.7				*	DISABLE INTERRUPT
			DJNZ R4,NOTDONE			*	SEE IF R4 IS NOT ZERO
			
			MOV R4,#0AH				*	RELOAD VALUE OF COUNTER
			CPL P1.7				*	COMPLEMENT FIRST PORT PIN
	
NOTDONE:	MOV TH0,#4CH			*	RELOAD TIMER
			MOV TL0,#00H			*	RELOAD TIMER
			SETB TCON.4				*	START TIMER   TR0=1
			SETB IE.7				*	ENABLE GLOBAL INTERRUPTS
			CLR P1.0				*	CLEAR SECOND PORT PIN
			RETI					*	RETURN FROM ISR
			
